package com.pkx.cloud.fse7.dms.deviceread.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.cloud.fse7.dms.deviceread.entity.DeviceRead;
import com.pkx.cloud.fse7.dms.deviceread.service.DeviceReadService;
import com.pkx.cloud.whzx.comn.ORpose;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 读头 控制器
 *
 * @author ly
 * @since 2020-10-14
 */
@RestController
@RequestMapping("/deviceread/device-read")
@Api(value = "读头", tags = "读头")
@Slf4j
@ORpose
public class DeviceReadController {

    @Autowired
    private DeviceReadService deviceReadService;

    @ApiOperation("读头分页列表")
    @GetMapping("/page")
    public Page<DeviceRead> page(Page page, DeviceRead deviceRead) {
        return deviceReadService.pageList(page, deviceRead);
    }

    @ApiOperation("读头列表")
    @GetMapping("/list")
    public List<DeviceRead> list(DeviceRead deviceRead) {
        return deviceReadService.listByEntity(deviceRead);
    }

    @ApiOperation("读头详情")
    @GetMapping(value = "/{id}")
    public DeviceRead selectById(@PathVariable("id") Long id) {
        return deviceReadService.selectById(id);
    }

    @GetMapping("/name/{id}")
    @ApiOperation("根据门禁id 获取门禁名称")
    public String getByReadId(@PathVariable(value = "id") String id) {
        return deviceReadService.getByReadId(id);
    }
}
